<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>获取前后时间和日期</title>
		<script type="text/javascript" src="jquery-3.6.0/jquery-3.6.0.js"></script>
	</head>
	<body>
		<p id="data"></p>
	</body>
	<script type="text/javascript">
		function getNextDate(date,day){
			var dd=new Date(date);
			dd.setDate(dd.getDate()+day);
			var Y=dd.getFullYear();
			var m=dd.getMonth()+1<10?"0"+(dd.getMonth()+1):dd.getMonth()+1;
			var d=dd.getDate()<10?"0"+dd.getDate():dd.getDate();
			return Y+"-"+m+"-"+d;
		}
			var today=new Date();
			var time=getNextDate(today,-1);
			$("#data").html(time);
	</script>
</html>
